import 'package:flutter/material.dart';
import 'package:flutter_widget/custom/custom_appbar.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:scrollable_list_tabview/scrollable_list_tabview.dart';

// ignore: must_be_immutable
class ScrollableListTableview extends StatefulWidget {
  String name;
  ScrollableListTableview({Key? key, required this.name}) : super(key: key);
  @override
  State<ScrollableListTableview> createState() =>
      _ScrollableListTableviewState();
}

class _ScrollableListTableviewState extends State<ScrollableListTableview> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppbar(widget.name, Theme.of(context).primaryColor),
      body: ScrollableListTabView(
        tabHeight: 48,
        tabs: [
          ScrollableListTab(
            tab: ListTab(
              activeBackgroundColor: Theme.of(context).primaryColor,
              label: const Text(
                '公告消息',
              ),
            ),
            body: ListView.builder(
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              itemCount: 20,
              itemBuilder: (_, index) => ListTile(
                leading: Container(
                  height: 40,
                  width: 40,
                  decoration: BoxDecoration(
                      shape: BoxShape.circle,
                      color: Theme.of(context).primaryColor),
                  alignment: Alignment.center,
                  child: Text(
                    (index + 1).toString(),
                    style: const TextStyle(color: Colors.white),
                  ),
                ),
                title: Text('公告消息 ${index + 1}'),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
